-
Notifications
You must be signed in to change notification settings - Fork 35
Align Spring Session MongoDB with WebSession API. #54
Conversation
Introduce new state to MongoSession denoting if a session is new or not. Only perform a save on a non-new MongoSession if it already exists in the MongoDB. Otherwise, throw an IllegalStateException. Resolved #47.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left some comments inline.
@@ -95,7 +95,19 @@ public MongoSession createSession() { | |||
|
|||
@Override | |||
public void save(MongoSession session) { | |||
this.mongoOperations.save(convertToDBObject(this.mongoSessionConverter, session), this.collectionName); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reported issue and this PR are for alignment with WebSession
API, which is a reactive thing, so we likely shouldn't make changes to MongoOperationsSessionRepository
.
We can revisit that depending on outcome of spring-projects/spring-session#1277 as ideally we'd make the behavior switch for all SessionRepository
implementations in sync.
.then(); | ||
} else { | ||
|
||
return findSession(session.getId()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While this works, you could do probably do a ReactiveMongoOperations#collectionExists
to optimize by removing deserialization cost from the mix, right?
You could also compose the implementation of this method in such way to avoid writing the duplicate ReactiveMongoOperations#save
call - see ReactiveRedisOperationsSessionRepository#save
for inspiration.
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://www.apache.org/licenses/ with 1 occurrences migrated to: https://www.apache.org/licenses/ ([https](https://www.apache.org/licenses/) result 200). * http://www.apache.org/licenses/LICENSE-2.0 with 33 occurrences migrated to: https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200). * http://www.apache.org/licenses/LICENSE-2.0.html with 2 occurrences migrated to: https://www.apache.org/licenses/LICENSE-2.0.html ([https](https://www.apache.org/licenses/LICENSE-2.0.html) result 200).
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * http://maven.apache.org/xsd/maven-4.0.0.xsd with 1 occurrences migrated to: https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200). * http://spring.io/projects/spring-session-data-mongodb with 1 occurrences migrated to: https://spring.io/projects/spring-session-data-mongodb ([https](https://spring.io/projects/spring-session-data-mongodb) result 200). * http://www.apache.org/licenses/LICENSE-2.0 with 4 occurrences migrated to: https://www.apache.org/licenses/LICENSE-2.0 ([https](https://www.apache.org/licenses/LICENSE-2.0) result 200). * http://static.springframework.org/spring/docs/4.1.x/javadoc-api (301) with 1 occurrences migrated to: https://docs.spring.io/spring/docs/4.1.x/javadoc-api ([https](https://static.springframework.org/spring/docs/4.1.x/javadoc-api) result 301). * http://docs.oracle.com/javase/6/docs/api with 1 occurrences migrated to: https://docs.oracle.com/javase/6/docs/api ([https](https://docs.oracle.com/javase/6/docs/api) result 302). * http://repo.spring.io with 2 occurrences migrated to: https://repo.spring.io ([https](https://repo.spring.io) result 302). * http://repo.spring.io/libs-snapshot with 1 occurrences migrated to: https://repo.spring.io/libs-snapshot ([https](https://repo.spring.io/libs-snapshot) result 302). # Ignored These URLs were intentionally ignored. * http://maven.apache.org/POM/4.0.0 with 2 occurrences * http://www.w3.org/2001/XMLSchema-instance with 1 occurrences
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed But Review Recommended These URLs were fixed, but the https status was not OK. However, the https status was the same as the http request or http redirected to an https URL, so they were migrated. Your review is recommended. * [ ] http://www.puppycrawl.com/dtds/configuration_1_3.dtd (404) with 1 occurrences migrated to: https://www.puppycrawl.com/dtds/configuration_1_3.dtd ([https](https://www.puppycrawl.com/dtds/configuration_1_3.dtd) result 404). * [ ] http://www.puppycrawl.com/dtds/suppressions_1_1.dtd (404) with 1 occurrences migrated to: https://www.puppycrawl.com/dtds/suppressions_1_1.dtd ([https](https://www.puppycrawl.com/dtds/suppressions_1_1.dtd) result 404). ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * [ ] http://maven.apache.org/xsd/maven-4.0.0.xsd with 1 occurrences migrated to: https://maven.apache.org/xsd/maven-4.0.0.xsd ([https](https://maven.apache.org/xsd/maven-4.0.0.xsd) result 200). * [ ] http://maven.apache.org/xsd/settings-1.0.0.xsd with 1 occurrences migrated to: https://maven.apache.org/xsd/settings-1.0.0.xsd ([https](https://maven.apache.org/xsd/settings-1.0.0.xsd) result 200). * [ ] http://spring.io/projects/spring-session-data-mongodb with 1 occurrences migrated to: https://spring.io/projects/spring-session-data-mongodb ([https](https://spring.io/projects/spring-session-data-mongodb) result 200). * [ ] http://static.springframework.org/spring/docs/4.1.x/javadoc-api (301) with 1 occurrences migrated to: https://docs.spring.io/spring/docs/4.1.x/javadoc-api ([https](https://static.springframework.org/spring/docs/4.1.x/javadoc-api) result 301). * [ ] http://docs.oracle.com/javase/6/docs/api with 1 occurrences migrated to: https://docs.oracle.com/javase/6/docs/api ([https](https://docs.oracle.com/javase/6/docs/api) result 302). * [ ] http://repo.spring.io with 2 occurrences migrated to: https://repo.spring.io ([https](https://repo.spring.io) result 302). * [ ] http://repo.spring.io/libs-snapshot with 1 occurrences migrated to: https://repo.spring.io/libs-snapshot ([https](https://repo.spring.io/libs-snapshot) result 302). # Ignored These URLs were intentionally ignored. * http://maven.apache.org/POM/4.0.0 with 2 occurrences * http://maven.apache.org/SETTINGS/1.0.0 with 2 occurrences * http://www.w3.org/2001/XMLSchema-instance with 2 occurrences
This commit updates URLs to prefer the https protocol. Redirects are not followed to avoid accidentally expanding intentionally shortened URLs (i.e. if using a URL shortener). # Fixed URLs ## Fixed Success These URLs were switched to an https URL with a 2xx status. While the status was successful, your review is still recommended. * [ ] http://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/ with 1 occurrences migrated to: https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/ ([https](https://docs.spring.io/spring-boot/docs/current/reference/htmlsingle/) result 200). * [ ] http://docs.spring.io/spring-session/docs/ with 1 occurrences migrated to: https://docs.spring.io/spring-session/docs/ ([https](https://docs.spring.io/spring-session/docs/) result 200). * [ ] http://projects.spring.io/spring-session-data-mongodb/ with 1 occurrences migrated to: https://projects.spring.io/spring-session-data-mongodb/ ([https](https://projects.spring.io/spring-session-data-mongodb/) result 200). * [ ] http://stackoverflow.com with 1 occurrences migrated to: https://stackoverflow.com ([https](https://stackoverflow.com) result 200). * [ ] http://stackoverflow.com/questions/tagged/spring-session with 1 occurrences migrated to: https://stackoverflow.com/questions/tagged/spring-session ([https](https://stackoverflow.com/questions/tagged/spring-session) result 200). * [ ] http://stackoverflow.com/tags/spring-session with 1 occurrences migrated to: https://stackoverflow.com/tags/spring-session ([https](https://stackoverflow.com/tags/spring-session) result 200). * [ ] http://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html with 1 occurrences migrated to: https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html ([https](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html) result 200). * [ ] http://contributor-covenant.org with 1 occurrences migrated to: https://contributor-covenant.org ([https](https://contributor-covenant.org) result 301). * [ ] http://contributor-covenant.org/version/1/3/0/ with 1 occurrences migrated to: https://contributor-covenant.org/version/1/3/0/ ([https](https://contributor-covenant.org/version/1/3/0/) result 301). * [ ] http://plugins.jetbrains.com/plugin/6546 with 1 occurrences migrated to: https://plugins.jetbrains.com/plugin/6546 ([https](https://plugins.jetbrains.com/plugin/6546) result 301). # Ignored These URLs were intentionally ignored. * http://localhost:8080/ with 2 occurrences
Revisit this issue in a clean PR (if still needed). |
Only perform a save after verifying the MongoSession already exists in MongoDB. Otherwise, throw an IllegalStateException.
Resolved #47.